﻿using System;

namespace Fourshapes
{
    /// <summary>
    /// 输出四种形状：直角三角形，等腰三角形，空心等腰三角形，空心菱形
    /// </summary>
    class Program
    {
        private const int LinesCount = 5;
        static void Main(string[] args)
        {
            Console.Clear();
            //直角三角形
            RightAngledTriangle();
            //等腰三角形
            IsoscelesTriangle();
            //空心三角形
            HollowTriangle();
            //空心菱形
            HollowDiamond();
            Console.ReadKey();
        }
        /// <summary>
        /// 输出直角三角形
        /// </summary>
        static void RightAngledTriangle()
        {
            Console.WriteLine("直角三角形:");
            for (int i = 0; i < LinesCount; i++)
            {
                Console.WriteLine(new String('*', i + 1));
            }
        }
        /// <summary>
        /// 输出等腰三角形
        /// </summary>
        static void IsoscelesTriangle()
        {
            Console.WriteLine("等腰三角形:");
            for (int i = 1; i <= LinesCount; i++)
            {
                for (int j = 1; j <= LinesCount - i; j++)
                {
                    Console.Write(" ");
                }
                for (int j = 1; j < 2 * i; j++)
                {
                    Console.Write("*");
                }
                Console.WriteLine("");
            }
        }
        /// <summary>
        /// 输出空心三角形
        /// </summary>
        static void HollowTriangle()
        {
            Console.WriteLine("空心三角形:");
            for (int i = 1; i <= LinesCount; i++)
            {
                for (int j = 1; j <= LinesCount - i; j++)
                {
                    Console.Write(" ");
                }
                for (int k = 1; k <= 2 * i - 1; k++)
                {
                    if (i >= LinesCount || k <= 1 || k == 2 * i - 1)
                    {
                        Console.Write("*");
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine("");
            }
        }
        /// <summary>
        /// 输出空心菱形
        /// </summary>
        static void HollowDiamond()
        {
            Console.WriteLine("空心菱形:");
            for (int i = 1; i <= LinesCount; i++)
            {
                for (int j = 1; j <= LinesCount - i; j++)
                {
                    Console.Write(" ");
                }
                if (i == 1)
                    Console.WriteLine("*");
                else
                {
                    Console.Write("*");
                    for (int j = 1; j <= 2 * i - 3; j++)
                    {
                        Console.Write(" ");
                    }
                    Console.WriteLine("*");
                }
            }
            for (int i = LinesCount - 1; i >= 1; i--)
            {
                for (int j = 1; j <= LinesCount - i; j++)
                {
                    Console.Write(" ");
                }
                if (i == 1)
                    Console.WriteLine("*");
                else
                {
                    Console.Write("*");
                    for (int j = 1; j <= 2 * i - 3; j++)
                    {
                        Console.Write(" ");
                    }
                    Console.WriteLine("*");
                }
            }

        }
    }
}
